

(defMethod process-markup-element
           ((element attlist-declaration) (context t))
  (xml-node.append-element (element-declaration (xml-node.reference element))
                           element))

(defMethod process-markup-element
           ((element comment) (stream t))
  (when *xml-preserve-comments*
    (xml-node.append-element *parent-node* element)))

(defMethod process-markup-element
           ((datum document-type) (stream t))
  "when reading an XML-stream a DOCTYPE form is read at the outset.
   the parsed document declaration is merged into the document.
   the effect is that the specified internal DTD is processed and if an external
   is specified that is loaded as well"
  (with-namespace-frame
    ;; push a namespace frame for bindings with the internal and/or
    ;; external subset. read the internal subset first.
    (with-slots (name internal system) datum
      (typecase internal
        (string (setf internal (read-dtd-stream internal)))
        (list )
        (t
         (xml-form-error datum
                        "illegitimate slot-value: ~s ~s ~s."
                        datum 'internal internal)))
      (when system
        (read-dtd-stream system))))

  (xml-node.append-element *parent-node* datum)
  datum)


(defMethod process-markup-element
           ((element element) (stream t))
  element)


(defun read-process-markupdecl (stream &aux declaration)
  (setf declaration )
  (cond (*xml-markup-ignore*)
        ((and declaration
              (setf declaration
                    (process-markup-element declaration *markup-stream*)))
         (setf *processed-node* declaration)))
  declaration)

(defun read-process-markup (stream &aux content)
  ;; iterate to EOF or until a section end marker is read.
  (setf content )
  (cond (*xml-markup-ignore*) ;; not strictly permitted since this is content
        ((and content
              (setf content
                    (process-markup-element content *markup-stream*)))
         (setf *processed-node* content)))
  content)

(defMethod process-markup-element
           ((node namespace-pi) (stream t))
  "bind a package to the namespace prefix within the scope of the present
   physical entity. 
   the prefix-uri binding has dynamic scope and extent,
   the uri-package binding indefinite scope and extent."
  (dolist (attribute (slot-value node 'attributes))
    (let ((prefix (attribute.name attribute))
          (name (attribute.value attribute)))
      (when (xml-verbose 'process-markup-element)
        (format *trace-output* "~%<!-- binding namespace: ~a=~a -->"
                prefix name)
        (assert-namespace-binding prefix name))))

  ;; side-effect only
  (values))

(defMethod process-markup-element :after
           ((node pi-node) (stream t))
  (xml-node.append-element *parent-node* node)
  node)


(defMethod process-markup-element
           ((node character-data) (stream t))
  (xml-node.append-element *parent-node* node))
